package com.manage.result;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

@Data
public class PageResult<T> {
    private Integer code;
    private String msg;
    private PageData<T> data;

    public static <T> PageResult<T> success(Page<T> page) {
        PageResult<T> result = new PageResult<>();
        result.setCode(200);
        result.setMsg("操作成功");
        PageData<T> pageData = new PageData<>();
        pageData.setPageNum((int) page.getCurrent());
        pageData.setPageSize((int) page.getSize());
        pageData.setTotal(page.getTotal());
        pageData.setList(page.getRecords());
        result.setData(pageData);
        return result;
    }
}

